package com.bydq.patrolsystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bydq.patrolsystem.entity.PsLogs;
import com.bydq.patrolsystem.mapper.PsLogsMapper;
import com.bydq.patrolsystem.service.PsLogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 写代码是不可能写代码的啦~~
 * @since 2020-05-22
 */
@Service
public class PsLogsServiceImpl extends ServiceImpl<PsLogsMapper, PsLogs> implements PsLogsService {
    @Autowired
    private PsLogsMapper psLogsMapper;

    @Override
    public IPage<PsLogs> selectPageByEditions(Integer currentPage, Integer pageSize, String start, String end, String userCode) {
        Page<PsLogs> psLogsPage = new Page<>(currentPage, pageSize);
        QueryWrapper<PsLogs> psLogsQueryWrapper = new QueryWrapper<PsLogs>().eq("userCode", userCode).
                ge(start!=null&&!start.equals(""),"operateDatetime", start)
                .le(end!=null&&!end.equals(""),"operateDatetime", end)
                .orderByDesc("operateDatetime");
        return psLogsMapper.selectPage(psLogsPage,psLogsQueryWrapper);
    }
}
